<template>
  <div v-if="height">
  
    <Chart :cdata="barArray[0]||cdata" :height="height" :colorArr="colorArr" />
  </div>
</template>

<script>
import Chart from './chart.vue'
export default {
  props:["height","colorArr","params"],
  data () {
    return {
      barArray:[],
      data:"",
      cdata: {
        category: [
          "甘州区",
          "民乐县",
          "临泽县",
          "高台县",
          "山丹县",
        ],
        lineData: [
          18092,
          20728,
          24045,
          28348,
          32808,
          
        ],
        barData: [
          4600,
          5000,
          5500,
          6500,
          7500,
         
        ],
        rateData: [0.25,0.33,0.45,0.41,0.22]
      }
    };
  },
  components: {
    Chart,
  },
  mounted () {
      this.getInfo({key:this.params}).then(res=>{
     
      const category=[]
      const barData=[]
      res.cockpitData.map(e=>{
        category.push(e.dimension||e.name)
        barData.push(e.measure||e.count)
      });
      const data={
        category,
        barData
      }
     
      this.barArray.push(data)
    })
    //this.setData();
    //const data=this.getInfo()
  },
  methods: {
    // 根据自己的业务情况修改
    setData () {
      for (let i = 0; i < this.cdata.barData.length -1; i++) {
        let rate = this.cdata.barData[i] / this.cdata.lineData[i];
        this.cdata.rateData.push(rate.toFixed(2));
      }
    },
  }
};
</script>

<style lang="scss" scoped>
</style>